<%@ page language="java" contentType="text/html; charset=US-ASCII"
    pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String serverId = request.getParameter("serverId");
	
%>
<div id="deploy-alert-container"></div>
<div class="panel panel-default" id="deploy-options-panel" >
	<div class="panel-heading">
		<i class="fa fa-cog"></i> <a data-toggle="collapse" href="#deployCollapse">Deploy Options</a>
		<div class="pull-right">
           <div class="btn-group">
               <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                   Actions
                   <span class="caret"></span>
               </button>
               <ul class="dropdown-menu pull-right" role="menu">
             	   <li><a  id="sendAdminEmail"><i class="fa fa-envelope-o fa-fw"></i>Contact Admin</a></li>
               </ul>
           </div>
       </div>
	</div>
	<div id="deployCollapse" class="panel-collapse collapse in">
		<div class="panel-body">
			 <form role="form" id="deploy-options-form">
			 			<div class="row">
			 				<div class="col-md-6">
			 					<div class="form-group">
			                        <label for="disabledSelect">Server Name:</label>
			                         <input id="serverId"  type="hidden" class="form-control"/>
			                         <input id="servername" type="text" class="form-control"  disabled/>
			                    </div>
			                    <div class="form-group">
			                        <label>Hostname</label>
			                         <input id="hostname"  type="text" class="form-control"  disabled/>
			                    </div>
			                    <div class="form-group">
			                        <label>Profile: </label>
			                         <input id="profileName" type="text" class="form-control" disabled />
			                    </div>
			                    <div class="form-group">
			                        <label>Profile Hostname: </label>
			                         <input id="profileHostname" type="text" class="form-control" disabled />
			                    </div>
			                    <div class="form-group">
			                        <label>Region:</label>
			                         <input id="region"  type="text" class="form-control" disabled />
			                    </div>
			                    
			 				</div>
			 				<div class="col-md-6">
			 					<div class="form-group">
			 						 <label>Enable Auto Restart:</label>
			                     	 <label class="checkbox">
	                                     <input id="autoRestartEnabled" type="checkbox">Auto Restart
	                                  </label>
	                                  <p class="help-block">Optional: Select to restart the Server after deployment</p>
			                    </div>
			                    <div class="form-group">
			 						 <label>Clear Cache:</label>
			                     	 <label class="checkbox">
	                                     <input id="clearCacheEnabled" type="checkbox">Clear Cache
	                                  </label>
	                                  <p class="help-block">Optional: Select to clear the cache after Deployment if available</p>
			                    </div>
			                    <div class="form-group">
			                     	<label>Send Email :</label>
			                     	 <input id="emailTo" class="form-control" />
			                     	 <p class="help-block">Optional: Send email after deployment</p>
			                    </div>
			                    <div class="form-group">
	                                  <label>Available Deployment Files:</label>
	                                  <select id="deployFiles" multiple class="form-control">
	                                  	 <option selected></option>
	                                  </select>
	                                  <p class="help-block">Select Files to deployment. Default is all. If you don't see any artifacts, contact the admin team</p>
	                            </div>
	                            <button type="button" id="deployApplication" class="btn pull-right btn-primary">Submit</button>
			 				</div>
			 				
						</div>
	          </form>
		</div> <!--  End of row div -->
	</div> <!--  End of Collapse -->
</div>
<script>
	 $(document).ready(function() {
	 	var serverId= parseInt("<%= serverId %>");
	 	uft.getDeploymentOptions(serverId);
	 	$("#deployApplication").click(function(){
	 		var obj={serverId:null, servername:null, autoRestartEnabled:null, clearCacheEnabled:null, emailTo:"", deployFiles:""}
	 		obj=dwr.util.getValues(obj);
	 		obj.deployFiles=obj.deployFiles.join();
	 		console.log(obj)
	 		uft.deployApplication(obj,"deploy-alert-container");
	 	})
	 })
</script>